<%

from yahoo.search.web import WebSearch

def _s(val):
    if form.has_key(val):
        return form[val]
    return ''
# end of_

%>

<html>
<head>
    <title>Kontext Search Page</title>
    <script type="text/javascript" src="slider/js/ajax-dynamic-content.js"></script>
    <script type="text/javascript" src="slider/js/ajax.js"></script>
    <script type="text/javascript" src="slider/js/ajax-tooltip.js">
    <link rel="stylesheet" href="slider/css/ajax-tooltip.css" media="screen" type="text/css">
</head>
<body>

    <img src="kontext/images/kontextMiniLogo.png" style="float:right"/>
    <div id="form" style="padding-top:30px;">
    <form action="" method="get">
        <input type="text" name="que" value="<%=_s('que')%>" style="border:1px solid #CCC" size=35>
        <input type="submit" name="search" value="search">
    </form>
    </div>

<%
if not _s('que')=='':
    srch = WebSearch("YahooDemo", query=form['que'], results=20)
    data = srch.parse_results()
    if len(data.results)>0:
        for result in data.results:
%>
    <h3><a href="summarize.py?url=<%=result['Url']%>&q=<%=_s('que')%>"
           onmouseover="ajax_showTooltip('summarize.py?url=<%=result["Url"]%>&q=<%=_s("que")%>&modal=true&options=limit:1000',this);return false"
           onmouseout="ajax_hideTooltip()"><%= result['Title'] %></a>
    <a href="<%=result['Url']%>">[»»]</a></h3>
    <div style="padding-left:10px;border-bottom:1px solid #CCC"><%=result['Summary']%></div><br>

<%
    else:
%>

    There is no search result about <b><%=_s('que')%></b>

<%
else:
%>

    You have to give a search criteria..
</html>
